import request from '@/axios';

export const getList = (positionSequenceId, data) => {
  return request({
    url: '/position/positionInstance/query',
    method: 'get',
    params: {
      positionSequenceId,
      ...data,
    },
  });
};

export const getDetail = id => {
  return request({
    url: '/position/positionInstance/detail',
    method: 'get',
    params: {
      id,
    },
  });
};

export const remove = ids => {
  return request({
    url: '/position/positionInstance/remove',
    method: 'post',
    params: {
      ids,
    },
  });
};

export const add = row => {
  return request({
    url: '/position/positionInstance/save',
    method: 'post',
    data: row,
  });
};

export const update = row => {
  return request({
    url: '/position/positionInstance/update',
    method: 'post',
    data: row,
  });
};

export const getStudyTime = positionInstanceId => {
  return request({
    url: '/position/positionKnowledge/classificationStudyTime',
    method: 'get',
    params: {
      positionInstanceId,
    },
  });
};

export const examInstance = positionInstanceId => {
  return request({
    url: '/position/examInstance/state',
    method: 'get',
    params: {
      positionInstanceId,
    },
  });
};

export const startExam = (positionInstanceId, newExam) => {
  return request({
    url: '/position/examInstance/startExam',
    method: 'post',
    params: {
      positionInstanceId,
      newExam,
    },
  });
};

export const examUserAnswer = (data) => {
  return request({
    url: '/position/examUserAnswer/update',
    method: 'post',
    data
  });
};

export const examInstanceSubmit = (examInstanceId) => {
  return request({
    url: '/position/examInstance/submit',
    method: 'post',
    params: {
      examInstanceId
    }
  });
};

